#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2016/08/14 21:29
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
"""


from wsgiref.simple_server import make_server

def index():
    return 'index'

def login():

    html = '''<p>UserName:<input/></p><p>PassWord<input/></p>'''
    return html

def abc():
        return '<h1>abc</h1><p><h1>test</h1>'

url = (
    ('/index',index),
    ('/manage',index),
    ('/login',login),
)


def runserver(environ, start_response):

    start_response('200 OK',[('content-Type', 'text/html')])


    #获取用户的URL
    userurl = environ['PATH_INFO']

    func = None

    for item in url:
        if item[0] == userurl:
            func = item[1]
            break

    if func:
        result = func()
    else:
        result = '404'

    return result



if __name__ == '__main__':
   httpd = make_server('',10101, runserver)
   print 'serving http on port 10101'
   httpd.serve_forever()
